package ipaintplugin.actions;

import ipaintplugin.Activator;
import ipaintplugin.objects.Figure;
import ipaintplugin.objects.Point;
import ipaintplugin.objects.Rectangle;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.graphics.GC;
import org.eclipse.ui.PlatformUI;

public class RectangleToolAction extends BaseToolAction {

	public RectangleToolAction() {
		setText("Rectangle Tool");
		setToolTipText("Draw Rectangle");

		setImageDescriptor(ImageDescriptor.createFromURL(FileLocator.find(
				Platform.getBundle(Activator.PLUGIN_ID), new Path(
						"icons/rectangle.png"), null)));

	}

	@Override
	public Figure getFigureInstance(MouseEvent min, MouseEvent max) {
		Rectangle rect = new Rectangle();
		rect.setMin(new Point(min.x, min.y));
		rect.setMax(new Point(max.x, max.y));
		return rect;
	}

}
